home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / lang / SmallEiffel.lha / SmallEiffel / lib_rand / gen_rand.e < prev    next >
Text File  |  1998-12-22  |  2KB  |  74 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://www.loria.fr/SmallEiffel
  11. --
  12. deferred class GEN_RAND
  13.    -- 
  14.    -- Here is the common way to use a random number generator.
  15.    -- Current implementations are MIN_STAND, STD_RAND.
  16.    --
  17.  
  18. feature {NONE} -- Creation procedures:
  19.  
  20.    make is
  21.      -- Create the generator with an automatic hazardous setting of
  22.      -- the `seed_value'.
  23.      -- Because automatic setting may be done using internal address
  24.      -- of Current for example, it may produces platform dependent 
  25.      -- behavior or compilation-mode dependant behavior.
  26.      -- Also consider `with_seed' to chose the most appropriate.
  27.       deferred
  28.       end;
  29.  
  30.    with_seed(seed_value: INTEGER) is
  31.      -- Create the generator with an explicit `seed_value'.
  32.       deferred
  33.       end;
  34.  
  35. feature
  36.    
  37.    next is
  38.      -- Compute next random number in sequence.
  39.       deferred
  40.       end;
  41.  
  42. feature -- No modifications :
  43.    
  44.    last_double: DOUBLE is
  45.      -- Look at the last computed number.
  46.      -- Range 0 to 1;
  47.       do
  48.      Result := last_real.to_double;
  49.       ensure
  50.      Result > 0 and Result < 1
  51.       end;
  52.    
  53.    last_real: REAL is
  54.      -- Look at the last computed number.
  55.      -- Range 0 to 1;
  56.       deferred
  57.       ensure
  58.      Result > 0 and Result < 1
  59.       end;
  60.    
  61.    last_integer(n:INTEGER):INTEGER is
  62.      -- Look the last computed number.
  63.      -- Range 1 to `n'.
  64.       require 
  65.      n >= 1
  66.       deferred
  67.       ensure
  68.      1 <= Result and Result <= n
  69.       end;
  70.  
  71. end -- GEN_RAND
  72.  
  73.  
  74.